package com.cloud.mall.exception;

import com.cloud.mall.response.R;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 全局异常处理器
 */
@ControllerAdvice
public class GlobalMallException {

    @ResponseBody
    @ExceptionHandler(Exception.class)
    public R allException(Exception e){
        return R.error().message(e.getMessage());
    }
}
